package com.wlc.base.sorting;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @author 王立朝
 * @date 2022/11/21
 * @description:
 */
public class Sort2 {

    public void test01() {
        List<UserInfo> list = new ArrayList<UserInfo>();
        list.add(new UserInfo("张三", 5));
        list.add(new UserInfo("李四", 30));
        list.add(new UserInfo("王五", 19));
        list.add(new UserInfo("王麻子", 17));

        list.sort(Comparator.comparing(UserInfo::getAge));
        list.stream().forEach(System.out::println);
    }

    public static void main(String[] args) {
        Sort2 sort2 = new Sort2();
        sort2.test01();
    }
}
